const filter = {
  userNickSplitFun: function (val) {
    if (val) {
      if (val.length > 2) {
        return val.slice(val.length - 2, val.length);
      } else {
        return val;
      }
    } else {
      return "无";
    }
  },
  baseTimeSplitFun: function (val) {
    if (val) {
      if (val.indexOf(" ") > -1) {
        return val.split(" ")[0];
      } else {
        return val;
      }
    } else {
      return "暂无";
    }
  },
  userCompSplitFun: function (val) {
    if (val) {
      if (val.length > 2) {
        return val.slice(0, 2);
      } else {
        return val;
      }
    } else {
      return "无";
    }
  },
  baseTimeIntegralFun: function (val, type) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      if (type == 'yyyy') {
        return y
      } else if (type == 'mm-dd') {
        return m + "-" + d
      } else if (type == 'hh:ff') {
        return h + ":" + f
      } else if (type == 'week') {
        var myddy = standardTime.getDay();
        var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
        return weekday[myddy]
      } else {
        return y + "-" + m + "-" + d + " " + h + ":" + f;
      }

    } else {
      return "暂无";
    }
  },
  baseTimeFun: function (val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return y + "-" + m + "-" + d + " " + h + ":" + f;
    } else {
      return "暂无";
    }
  },
  baseGYMDTimeFun: function (val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      m = m > 9 ? m : "0" + m;
      d = standardTime.getDate();
      d = d > 9 ? d : "0" + d;
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return y + "-" + m + "-" + d;
    } else {
      return "暂无";
    }
  },
  baseDateFun: function (val) {
    if (val) {
      var standardTime = new Date(Number(val));
      var y, m, d, h, f;
      y = standardTime.getFullYear();
      m = standardTime.getMonth() + 1;
      d = standardTime.getDate();
      h = standardTime.getHours();
      h = h > 9 ? h : "0" + h;
      f = standardTime.getMinutes();
      f = f > 9 ? f : "0" + f;
      return m + "月" + d + '号';
    } else {
      return "暂无";
    }
  },
  baseVolumeFun: function (val) {
    if (val) {
      if (val * 1 > 1000) {
        return `${val * 1 / 1000}k`
      } else {
        return val
      }
    } else {
      return 0;
    }
  },
  baseStrFun: function (val) {
    if (val) {
      return val;
    } else {
      return "暂无";
    }
  },
  baseNumberFun: function (val) {
    if (val) {
      return val;
    } else {
      return "0";
    }
  },
  baseLogoFil: function (val) {
    if (val) {
      if (val.indexOf("http") > -1) {
        return val;
      } else {
        return "/static/img/11@3x.png";
      }
    } else {
      return "/static/img/11@3x.png";
    }
  },
};
export default filter;
